package com.lxw.study.structural.flyweight;

import java.util.HashMap;
import java.util.Map;

public class CharFactory {
    private static final Map<java.lang.Character, Character> charPool = new HashMap<>();

    public static CharFlyweight getCharacter(char value) {
        if (!charPool.containsKey(value)) {
            charPool.put(value, new Character(value));
        }
        System.out.println(charPool.size());
        return charPool.get(value);
    }
}
